<?php
/**
 * 获取卡券基本信息
 */
require_once('common.php');
$cardinfourl = 'https://api.weixin.qq.com/card/get?access_token=';

$access_token = get_access_token();
$card_id = $_GET['card_id'];
if(empty($card_id)){
    echo_Json(-1, 'card_id不能为空');
}
$data = array(
    'card_id' => $card_id
);
$result = getCardInfo($cardinfourl . $access_token, $data, true);
if($result['code'] != 0){
    echo_Json($result['code'], '卡券信息获取失败');
}else{
    echo_Json(0, '卡券信息获取成功', $result['card']);
}

function getCardInfo($url, $data){
    $cardInfo_Arr = jsonpostJson($url, $data, true); //post请求
    if($cardInfo_Arr['errcode'] != 0){
        $result = array(
            'code' => $cardInfo_Arr['errcode'],
        );
    }else{
        $result = array(
            'code' => 0,
            'card' => $cardInfo_Arr['card']
        );
    }
    return $result;
}
